<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('施工资料列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>资料类型：</label>
                            <select name="imType" th:with="type=${@dict.getType('')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>资料名称：</label>
                            <input type="text" name="imName"/>
                        </li>
                        <li>
                            <label>上传资料：</label>
                            <input type="text" name="imData"/>
                        </li>
                        <li class="select-time">
                            <label>上传时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginImTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endImTime]"/>
                        </li>
                        <li>
                            <label>上传人：</label>
                            <input type="text" name="imTheHeir"/>
                        </li>
                        <li>
                            <label>备注：</label>
                            <input type="text" name="imRemark"/>
                        </li>
                        <li>
                            <label>项目信息：</label>
                            <input type="text" name="imPro"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('ruoyi:impl:remove')}]];
    var creadFlag = [[${@permission.hasPermi('ruoyi:completed:add')}]];
    //工程文件字典类型
    var beType = [[${@dict.getType('sys_be_type')}]];
    var prefix = ctx + "system/building";
    var prefixs = ctx + "ruoyi/impl";


    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefixs + "/add/{id}",
            exportUrl: prefix + "/export",
            removeUrl: prefixs + "/remove",
            modalName:"",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            detailView: true,
            onExpandRow: function (index, row, $building) {
                initChildTable(index, row, $building);
            },

            columns: [{
                checkbox: true
            },
                {
                    field: 'pId',
                    title: '项目id',
                    visible: false
                },
                {
                    field: 'pName',
                    title: '项目名称'
                },
                {
                    field: 'pTime',
                    title: '项目日期'
                },
                {
                    field: 'pFounder',
                    title: '项目经理'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success ' + creadFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.pId + '\')"><i class="fa fa-add"></i>添加</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    initChildTable = function (index, row, $building) {
        var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: prefixs  + "/lists",
            updateUrl: prefixs + "/edit/{pFileId}",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            queryParams: {
                sid:row.pId
            },
            columns: [
                {
                    field: 'imId',
                    title: '资料id',
                    visible: false
                },
                {
                    field: 'imType',
                    title: '资料类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(beType, value);
                    }
                },
                {
                    field: 'imName',
                    title: '资料名称',
                },
                {
                    field: 'imData',
                    title: '上传资料',
                    formatter: function(value, row, index) {
                        return '<a href="javascript:downloadFile(\''+row.imData+'\')">下载</a>';
                    }
                },
                {
                    field: 'imTime',
                    title: '上传时间'
                },
                {
                    field: 'imTheHeir',
                    title: '上传人'
                },
                {
                    field: 'imRemark',
                    title: '备注'
                },
                {
                    field: 'imPro',
                    title: '项目信息',
                    visible: false

                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.imId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }

            ]
        });
    };
    function downloadFile(pUploading) {
        window.location.href=ctx+"common/download/resource?resource="+pUploading;
    }
</script>
</body>
</html>